#include<iostream>
#include<pthread.h>
#include<unistd.h>

void* thread_run(void*arg)
{
	while(1)
	{
		std::cout<<"i am new thread"<<std::endl;
		sleep(2);
	}

	return nullptr;
}

int main()
{
	pthread_t th;
	pthread_create(&th,nullptr,thread_run,nullptr);	
	int cnt=0;	
	int retval;
	while(1)
	{
		std::cout<<"i am old thread"<<std::endl;
		sleep(2);
		if(cnt++>=3)
		//pthread_cancel(pthread_self());
		pthread_exit(&retval);
	}

	return 0;
}
